import {
    Controller,
    Get,
    Post,
    Body,
    Patch,
    Param,
    Query,
    Res,
    Req
  } from '@nestjs/common';
  import { <%= className %>Service } from './<%= tableInfo.table_name %>.service';
  import { 
    Create<%= className %>Dto,
    Update<%= className %>Dto,
    Query<%= className %>Dto,
    Delete<%= className %>Dto
  } from './dto/<%= tableInfo.table_name %>.dto';
  import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
  import { Response,Request } from 'express';
  import { RequirePermission } from 'src/decorator/reuqire-permission';
  
  @ApiTags('<%= tableInfo.function_name %>管理')
  @Controller('<%= tableInfo.table_name %>')
  @ApiBearerAuth()
  export class <%= className %>Controller {
    constructor(private readonly <%= tableInfo.table_name %>Service: <%= className %>Service) {}
  
    @Post()
    @ApiOperation({ summary: '创建<%= tableInfo.function_name %>' })
    @RequirePermission("<%=permissionPrefix%>:add")
    create(@Body() create<%= className %>Dto: Create<%= className %>Dto,@Req() req:Request) {
      return this.<%= tableInfo.table_name %>Service.create(create<%= className %>Dto,req);
    }
  
    @Get()
    @ApiOperation({ summary: '<%= tableInfo.function_name %>列表' })
    @RequirePermission("<%=permissionPrefix%>:list")
    findAll(@Query() query: Query<%= className %>Dto) {
      return this.<%= tableInfo.table_name %>Service.findAll(query);
    }
  
    @Get(':id')
    @ApiOperation({ summary: '<%= tableInfo.function_name %>详情' })
    @RequirePermission("<%=permissionPrefix%>:get")
    findOne(@Param('id') id: string) {
      return this.<%= tableInfo.table_name %>Service.findOne(+id);
    }
  
    @Patch(':id')
    @ApiOperation({ summary: '修改<%= tableInfo.function_name %>' })
    @RequirePermission("<%=permissionPrefix%>:edit")
    update(@Param('id') id: string, @Body() update<%= className %>Dto: Update<%= className %>Dto,@Req() req:Request) {
      return this.<%= tableInfo.table_name %>Service.update(+id, update<%= className %>Dto,req);
    }
  
    @Post('delete')
    @ApiOperation({ summary: '删除<%= tableInfo.function_name %>' })
    @RequirePermission("<%=permissionPrefix%>:remove")
    remove(@Body() dto: Delete<%= className %>Dto) {
      return this.<%= tableInfo.table_name %>Service.remove(dto.ids);
    }
  
    @Post('excel')
    @ApiOperation({ summary: '导出<%= tableInfo.function_name %>' })
    @RequirePermission("<%=permissionPrefix%>:export")
    exportToExcel(@Res() res: Response) {
      return this.<%= tableInfo.table_name %>Service.exportToExcel(res);
    }
  }
  